package com.example.tests;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import java.util.Set;

import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

public class ContactRemovalTests extends TestBase {
        Random rnd = new Random();

        @DataProvider(name = "removeRandomContact")
        public Iterator<Object[]> removeRandomContacts() {
                Set<ContactObject> contacts = app.getContactHelper().getContacts();
                ContactObject anyContact = contacts.iterator().next();
                
                List<Object[]> list = new ArrayList<Object[]>();

                list.add(new Object[]{anyContact});
                return list.iterator();
        }

        @Test(dataProvider = "removeRandomContact")
        public void testValidContactCanBeRemoved(ContactObject anyContact) throws Exception {
                
                Set<ContactObject> oldList = app.getContactHelper().getContacts();
//              for (int j=0;j<20;j++){
                        app.getContactHelper().deleteContact(anyContact);       
//              }
                Set<ContactObject> newList = app.getContactHelper().getContacts();
                verifyContactRemoved (oldList, anyContact, newList);
        }
}
